
import settings
from exts import bootstrap, db
from exts.logging import get_logger
from flask import Flask
from flask_session import Session
from flask_wtf import CSRFProtect


def create_app():
    app = Flask(__name__, template_folder='./templeates/', static_folder='./static/')
    
    app.config.from_object(settings.Development)
    
    db.init_app(app) # 初始化db插件
    bootstrap.init_app(app) # 初始化bootstrap插件
    
    Session(app)
    # csrf = CSRFProtect(app)
    # csrf.init_app(app)
    
    from apps.blueprints.article.view import article_bp
    from apps.blueprints.user.view import user_bp
    
    get_logger('app', settings.Config.LOG_FILE)

    # from apps.blueprints.goods.view import goods_bp
    
    
    app.register_blueprint(user_bp,url_prefix='/')
    app.register_blueprint(article_bp,url_prefix='/article')
    # app.register_blueprint(goods_bp,url_prefix='/goods')
    
    # print(app.url_map)
    
    return app